﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Person.aspx.cs" Inherits="Person_Person" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="body" Runat="Server">


    <asp:Button ID="Button2" runat="server" Text="Add Person"  class="google-button-blue"
        style="width:150px; margin-top:2%; margin-right:5%; height:30px; float:right" 
        onclick="Button2_Click" />

    <div style="background-color:White; padding:2.5%">

        <asp:Label ID="lbPesonHeading" runat="server" Text="Person" Font-Bold="True" 
            Font-Size="X-Large"></asp:Label>
    <asp:Panel ID="pnlAdd" runat="server" Visible="False">
        <br />
    <asp:Table ID="Table1" runat="server" CellPadding="1" 
            CellSpacing="0">
        <asp:TableRow>
            <asp:TableCell>
                <asp:Label ID="lbIDNo" runat="server" Text="ID No: "></asp:Label>
            
            </asp:TableCell>
            <asp:TableCell>
                <asp:TextBox ID="txtIDNo" runat="server" ReadOnly="True" BorderStyle="None"></asp:TextBox>
            
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>
                <asp:Label ID="lbFirstName" runat="server" Text="FirstName: "></asp:Label>
            
            </asp:TableCell>
            <asp:TableCell>
                <asp:TextBox ID="txtFirstName" runat="server" ReadOnly="True" BorderStyle="None"></asp:TextBox>
            
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>
                <asp:Label ID="lbSurname" runat="server" Text="Surname: "></asp:Label>
            
            </asp:TableCell>
            <asp:TableCell>
                <asp:TextBox ID="txtSurname" runat="server" ReadOnly="True" BorderStyle="None"></asp:TextBox>
            
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>
                <asp:Label ID="lbTelephone" runat="server" Text="Telephone: "></asp:Label>
            
            </asp:TableCell>
            <asp:TableCell>
                <asp:TextBox ID="txtTelephone" runat="server" ReadOnly="True" BorderStyle="None"></asp:TextBox>
            
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>
                <asp:Label ID="lbCellPhone" runat="server" Text="Cell Phone: "></asp:Label>
            
            </asp:TableCell>
            <asp:TableCell>
                <asp:TextBox ID="txtCellPhone" runat="server" ReadOnly="True" BorderStyle="None"></asp:TextBox>
            
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>
                    <asp:Button ID="btnUpdate" runat="server" Text="Update Area" class="button" 
                    style="width:150px; height:30px; top: 0px; left: 0px;" 
                        onclick="btnUpdate_Click" Visible="False" />
            
            </asp:TableCell>
            <asp:TableCell>
                    <asp:Button ID="btnCancle" runat="server" Text="Cancle Update" class="button" 
                    style="width:150px; height:30px; top: 0px; left: 0px;" 
                        onclick="btnCancle_Click" Visible="False" />
            
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>
                    <asp:Button ID="btnEdit" runat="server" Text="Edit Area" class="button" 
                    style="width:150px; height:30px; top: 0px; left: 0px;" 
                        onclick="btnEdit_Click" Visible="False" />
            
            </asp:TableCell>
            <asp:TableCell>
                    <asp:Button ID="btnDelete" runat="server" Text="Delete Area" class="button" 
                    style="width:150px; top: 0px; left: 0px;" 
                        OnClientClick="return confirm('Are you sure you want to delete this item?');" 
                        onclick="btnDelete_Click" Visible="False" Enabled="True" PostBackUrl="~/Person/Person.aspx" />
            
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>
                <asp:Button ID="btnAdd" runat="server" Text="Add Person" class="button"
                    style="width:150px; height:30px; top: 0px; left: 0px;" onclick="btnAdd_Click1" PostBackUrl="~/Person/Person.aspx" />
            </asp:TableCell>
            <asp:TableCell>
                    <asp:Button ID="btnCancleAdd" runat="server" Text="Cancle" class="button" 
                    style="width:150px; top: 0px; left: 0px;" 

                        Visible="True" Enabled="True" PostBackUrl="~/Person/Person.aspx" />
            
            </asp:TableCell>
        </asp:TableRow>

    </asp:Table>
    </asp:Panel>
    <br />
        <asp:Label ID="lbAddMsg" runat="server" Text="Successfully added." 
            ForeColor="#009900" Visible="False"></asp:Label>
    <br />
    <br />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            CellPadding="5" CellSpacing="2" DataKeyNames="ID_No" 
            DataSourceID="AccessDataSource1" 
            onselectedindexchanging="GridView1_SelectedIndexChanging" 
            AutoGenerateDeleteButton="True">
            <Columns>
                <asp:CommandField ShowEditButton="True" />
                <asp:BoundField DataField="ID_No" HeaderText="ID_No" ReadOnly="True" 
                    SortExpression="ID_No" />
                <asp:BoundField DataField="Firstname" HeaderText="Firstname" 
                    SortExpression="Firstname" />
                <asp:BoundField DataField="Surname" HeaderText="Surname" 
                    SortExpression="Surname" />
                <asp:BoundField DataField="Telephone" HeaderText="Telephone" 
                    SortExpression="Telephone" />
                <asp:BoundField DataField="CellPhone" HeaderText="CellPhone" 
                    SortExpression="CellPhone" />
            </Columns>
        </asp:GridView>



        <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
            DataFile="~/App_Data/Database.accdb" 
            SelectCommand="SELECT * FROM [Person]" 
            OldValuesParameterFormatString="original_{0}" 
            DeleteCommand="DELETE FROM [Person] WHERE ([ID_No] = ?) " 
            InsertCommand="INSERT INTO [Person] ([ID_No], [Firstname], [Surname], [Telephone], [CellPhone]) VALUES (?, ?, ?, ?, ?)" 
            UpdateCommand="UPDATE [Person] SET [Firstname] = ?, [Surname] = ?, [Telephone] = ?, [CellPhone] = ? WHERE (([ID_No] = ?))">
            <DeleteParameters>
                <asp:Parameter Name="original_ID_No" Type="String" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="ID_No" Type="String" />
                <asp:Parameter Name="Firstname" Type="String" />
                <asp:Parameter Name="Surname" Type="String" />
                <asp:Parameter Name="Telephone" Type="String" />
                <asp:Parameter Name="CellPhone" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="Firstname" Type="String" />
                <asp:Parameter Name="Surname" Type="String" />
                <asp:Parameter Name="Telephone" Type="String" />
                <asp:Parameter Name="CellPhone" Type="String" />
                <asp:Parameter Name="original_ID_No" Type="String" />
            </UpdateParameters>
        </asp:AccessDataSource>



    </div>

















</asp:Content>

